$(function(){
//	获取手机号
	var d={};
	d.token=token;
	$.ajax({
	    type:"post",
	    url:url+'/user/changepay.html?token='+token,
	    async:false,
	    data:d,
	    dataType:'json',
	    success:function(result){
	        if(result.status == "0001"){
	        	$(".phone").html(result.data.phone).attr("data",result.data.quhao);
	        }else{
	            isErr(result);
	        }
	    },
		error:function(){
			layer.msg("响应失败");
		}
	})
	
	
//	发送验证码
	$("#second").on("click",function() {
		$("#second").prop("disabled",true);
		var phone = $(".phone").html();
		var quhao=$(".phone").attr("data");
		var d = {};
		d.phone = phone;
		d.quhao=quhao;
		d.token=token;
		$.ajax({
			type: "post",
			url: url + '/site/sendmsg.html',
			data: d,
			dataType: 'json',
			success: function(result) {
				if(result.status == '0001') {
					//倒计时
					var time = 60;
					$("#second").html(time + "秒后重发");
					setInterval(function() {
						time--;
						if(time === 0) {
							$("#second").html("获取验证码");
							$("#second").prop("disabled",false);
						} else if(time > 0) {
							$("#second").html(time + "秒后重发");
						}
					}, 1000);

				} else {
					isErr(result);
					$("#second").prop("disabled",false);
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				layer.msg("请求失败：" + XMLHttpRequest.status);
			}
		});

	});
	
	
//	修改安全密码
var prevent_repetition=true;
	$(".payment_btn").on("click",function(){
		if(prevent_repetition){
			prevent_repetition=false;
			var new_pwd=$(".traspass").val();
			var qr_newpay=$(".traspass_1").val();
			var phone=$(".phone").html();
			var quhao=$(".phone").attr("data");
			var code=$(".code").val();
			if(!code){
				layer.msg("请输入验证码");
				prevent_repetition=true;
				return false;
			}
			if(!new_pwd){
				layer.msg("请输入新密码");
				prevent_repetition=true;
				return false;
			}
			if(!qr_newpay){
				layer.msg("请再次输入新密码");
				prevent_repetition=true;
				return false;
			}
			if(new_pwd != qr_newpay){
				layer.msg("两次密码输入不一致");
				prevent_repetition=true;
				return false;
			}
			var d={};
			d.phone=quhao+""+phone;
			d.token=token;
			d.new_pwd=new_pwd;
			d.qr_newpay=qr_newpay;
			d.code=code;
			layer.alert('是否确认钱包地址？', {
                closeBtn: 0    // 是否显示关闭按钮
                ,anim: 6 //动画类型
                ,btn: ['确认','取消'] //按钮
                ,yes:function(){
                    $.ajax({
						type:"post",
						url:url+'/user/alterpaypwd.html?token='+token,
						async:false,
						data:d,
						dataType:'json',
						success:function(result){
							if(result.status == "0001"){
								layer.msg(result.message);
								location.href='my_information1.html';
							}else{
								isErr(result);
							}
						},
						error:function(){
							layer.msg("响应失败");
						},
						complete: function() {
							prevent_repetition = true;
						}
					})
                }
                ,btn2:function(){

                }
            });
			
		}
	})
})
